package com.huawei.statistics.service.impl.admin;

import com.huawei.statistics.pojo.admin.SystemInfo;
import com.huawei.statistics.service.admin.SystemInfoService;
import com.huawei.statistics.service.impl.common.BaseServiceImpl;
import com.huawei.statistics.vo.common.HttpResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 18573 on 2018/12/29.
 */

@Service
public class SystemInfoServiceImpl extends BaseServiceImpl implements SystemInfoService{

    @Override
    public SystemInfo getSystemInfo() {
        List<SystemInfo> list = loadAllEntity(SystemInfo.class);
        return list.get(0);
    }

    @Override
    public HttpResult addOrUpdateSystemInfo(SystemInfo info) {

        Boolean targ = false;
        List<SystemInfo> list = loadAllEntity(SystemInfo.class);
        if(list != null && list.size() > 0){
            info.setId(list.get(0).getId());
           targ = updateEntityValues(info);
        }else{
            targ = addEntity(info);
        }
        return new HttpResult(HttpResult.OK,targ);
    }
}
